#!/bin/bash

echo "install lsof..."
rpm -ivh DS-RPMS/lsof-4.87-6.el7.x86_64.rpm

echo "install perl..."
rpm -ivh DS-RPMS/perl-5.16.3-295.el7.x86_64.rpm \
         DS-RPMS/perl-Carp-1.26-244.el7.noarch.rpm \
         DS-RPMS/perl-Encode-2.51-7.el7.x86_64.rpm \
         DS-RPMS/perl-Error-0.17020-2.el7.noarch.rpm \
         DS-RPMS/perl-Exporter-5.68-3.el7.noarch.rpm \
         DS-RPMS/perl-File-Path-2.09-2.el7.noarch.rpm \
         DS-RPMS/perl-File-Temp-0.23.01-3.el7.noarch.rpm \
         DS-RPMS/perl-Filter-1.49-3.el7.x86_64.rpm \
         DS-RPMS/perl-Getopt-Long-2.40-3.el7.noarch.rpm \
         DS-RPMS/perl-HTTP-Tiny-0.033-3.el7.noarch.rpm \
         DS-RPMS/perl-PathTools-3.40-5.el7.x86_64.rpm \
         DS-RPMS/perl-Pod-Escapes-1.04-295.el7.noarch.rpm \
         DS-RPMS/perl-Pod-Perldoc-3.20-4.el7.noarch.rpm \
         DS-RPMS/perl-Pod-Simple-3.28-4.el7.noarch.rpm \
         DS-RPMS/perl-Pod-Usage-1.63-3.el7.noarch.rpm \
         DS-RPMS/perl-Scalar-List-Utils-1.27-248.el7.x86_64.rpm \
         DS-RPMS/perl-Socket-2.010-5.el7.x86_64.rpm \
         DS-RPMS/perl-Storable-2.45-3.el7.x86_64.rpm \
         DS-RPMS/perl-TermReadKey-2.30-20.el7.x86_64.rpm \
         DS-RPMS/perl-Text-ParseWords-3.29-4.el7.noarch.rpm \
         DS-RPMS/perl-Time-HiRes-1.9725-3.el7.x86_64.rpm \
         DS-RPMS/perl-Time-Local-1.2300-2.el7.noarch.rpm \
         DS-RPMS/perl-constant-1.27-2.el7.noarch.rpm \
         DS-RPMS/perl-libs-5.16.3-295.el7.x86_64.rpm \
         DS-RPMS/perl-macros-5.16.3-295.el7.x86_64.rpm \
         DS-RPMS/perl-parent-0.225-244.el7.noarch.rpm \
         DS-RPMS/perl-podlators-2.5.1-3.el7.noarch.rpm \
         DS-RPMS/perl-threads-1.87-4.el7.x86_64.rpm \
         DS-RPMS/perl-threads-shared-1.43-6.el7.x86_64.rpm

echo "install vim..."
rpm -ivh DS-RPMS/vim-filesystem-7.4.629-6.el7.x86_64.rpm \
         DS-RPMS/vim-common-7.4.629-6.el7.x86_64.rpm \
         DS-RPMS/gpm-libs-1.20.7-6.el7.x86_64.rpm \
         DS-RPMS/vim-enhanced-7.4.629-6.el7.x86_64.rpm

echo "install git..."
rpm -ivh DS-RPMS/perl-Git-1.8.3.1-23.el7_8.noarch.rpm \
         DS-RPMS/git-1.8.3.1-23.el7_8.x86_64.rpm

echo "install nodejs..."
rpm -ivh DS-RPMS/nodejs-10.21.0-1nodesource.x86_64.rpm

npm config set registry https://registry.npm.taobao.org/

cat<<EOF
TIPS:
    # if 8083 not work
    systemctl stop firewalld
    # see ds config
    cat /etc/onlyoffice/documentserver/local.json
    # modify sample config
    vim OnlineEditorsExampleNodeJS/config/defalut.json
    # run sample
    npm start
EOF

cd ExampleNodeJS
npm i
npm start
